<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>五角星评分案例</title>
    <style>
        body {
            font-family: "simsun";
        }

        .comment {
            font-size: 40px;
            color: #ff1100;
        }

        .comment li {
            float: left;
            cursor: pointer;
        }

        ul {
            list-style: none;
        }
    </style>
    <script src="./jquery-1.11.1.js"></script>
</head>

<body>


    <ul class="comment">
        <li>☆</li>
        <li>☆</li>
        <li>☆</li>
        <li>☆</li>
        <li>☆</li>
    </ul>
    <script>
        $(function () {
            let KX_WJX = '☆'
            let SX_WJX = '★'
            $('.comment li').on('mouseenter', function () {
                $(this).text(SX_WJX).prevAll("li").text(SX_WJX)
                $(this).nextAll("li").text(KX_WJX)
            })
            $('.comment li').on('click', function () {
                $(this).addClass('current').siblings('li').remove('class')
            })
            $('.comment').on('mouseleave', function () {
                if($(".current").length == 0){
                    $(".comment li").text(KX_WJX)
                }else{
                    $(".current").text(SX_WJX).prevAll("li").text(SX_WJX)
                    $(".current").nextAll("li").text(KX_WJX)
                }
            })
        })
            
    </script>

</body>

</html>